<%@ page contentType="text/html;charset=UTF-8"%>
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="${staticWebsite}js/jquery-1.7.2.js"></script>
<link rel="stylesheet" href="${staticWebsite}css/admin.css" type="text/css" />
<link rel="stylesheet" href="${staticWebsite}css/validation.css" type="text/css" />
<script type="text/javascript" src="${staticWebsite}js/jquery.form.validation.js"></script>
<title>Insert title here</title>
<script type="text/javascript">
	$(document).ready(function(){
		<%--$("form").submit(function(){
			var flag = true;
			if($.trim($(":input[type='file']:eq(0)").val()) == ""){
				alert("请选择图片，或者点击关闭按钮退出此页！");
				return false;
			}
			$(":input[type='file']").each(function(){
				if($.trim($(this).val()) != "" && ! /^.+(\.jpg|\.JPG|\.gif|\.GIF|\.png|.PNG|\.x\-png|\.bmp|\.BMP)$/.test($(this).val())){
					alert("文件格式应为:jpg|gif|png|bmp！");
					$(this).focus();
					flag = false;
					return false;
				}
			});
			return flag;
		});
		$("form").validate({type:2,imageUrlHead:"${staticWebsite}admin/"});--%>
	if(${flag}){
		var arr = new Array();
		$(".returnURL").each(function(i){
			thisObj = $(this);
			arr[i] = thisObj.val();
		});
		if("${pos}" != null || "${pos}" != "")
			arr.push("${pos}");
		if(${doType} == "2")
		{
			self.parent.modifyPreview(arr);
		}else{
			self.parent.preview(arr);
		}
		self.parent.tb_remove();
	}
	
	$(".addMore").live("click",function(){
		 $(this).parent().parent().before("<tr><td><input type='file' name='images' dataType='isImage' /></td></tr>");
	});
	
	$("#close").click(function(){
		self.parent.tb_remove();
	});
	});
</script>
</head>
<body>
<br/>
<br/>
	<c:choose>
		<c:when test="${flag}">
			<c:forEach items="${imageURLList}" var="url" >
				<input type="hidden" class="returnURL" value="${url}" />
			</c:forEach>
		</c:when>
	</c:choose>
	<form action="${website}upload/upload_upload_imageUpload.action"  method="post" target="_self" enctype="multipart/form-data">
		<table style="width: 600px">
			<tr>
				<td>添加图片</td>
			</tr>
			<c:choose>
				<c:when test="${number == 0}">
					<tr>
						<td><input type="file" dataType="isImage" name="images" dataType="notNull"/></td>
					</tr>
					<tr>
						<td class="rightAlign"><a href="#" class="addMore">再添加一张</a></td>
					</tr>
				</c:when>
				<c:otherwise>
					<c:forEach begin="1" end="${number}" >
						<tr>
							<td><input type="file" name="images" dataType="isImage" /></td>
						</tr>
					</c:forEach>
				</c:otherwise>
			</c:choose>
			<tr>
				<td align="center"><input type="hidden" value="${pos}" name="pos"  /><input type="hidden" value="${type}" name="type" /><input type="hidden" name="doType" value="${doType}" /><input type="hidden" value="${number}" name="number"  /><input type="submit" value="提交" /><input type="button" id="close" value="关闭" /></td>
			</tr>
		</table>
	</form>
</body>
</html>